<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Models\Post;
use App\Http\Models\Comment;

class CommentController extends Controller
{
    //
	public function submitComment ( Request $request, Post $post )
	{
		$id = \Auth::id();

		if(!$id){
			return redirect('/login/index');
		}

		$this->validate($request,[
			'content' => 'required|min:3'
		]);

		$model = new Comment();
		$model->post_id = $post->id;
		$model->user_id = $id;
		$model->content = $request['content'];
		$model->save();


		return back();


	}
}
